package com.zxz.springbootredis.utils;

import lombok.Data;
import lombok.Getter;

@Data
public class JsonResult {
    // 状态码：200=成功，500=失败
    private int code;
    // 响应消息
    private String message;
    // 响应数据（可选）
    private Object data;

    // 成功响应静态方法
    public static JsonResult success(String message, Object data) {
        JsonResult result = new JsonResult();
        result.code = 200;
        result.message = message;
        result.data = data;
        return result;
    }

    // 失败响应静态方法
    public static JsonResult failed(String message) {
        JsonResult result = new JsonResult();
        result.code = 500;
        result.message = message;
        result.data = null;
        return result;
    }


    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public Object getData() {
        return data;
    }


}